package cn.hk.vaccination.service.impl;

import cn.hk.vaccination.domain.DeptVaccinesStock;
import cn.hk.vaccination.domain.vo.VaccinationVo;
import cn.hk.vaccination.mapper.DeptVaccinesStockMapper;
import cn.hk.vaccination.service.DeptVaccinesStockService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 社区对应的疫苗库存 服务实现类
 * </p>
 *
 * @author xu
 * @since 2023-03-10
 */
@Service
public class DeptVaccinesStockServiceImpl extends ServiceImpl<DeptVaccinesStockMapper, DeptVaccinesStock> implements DeptVaccinesStockService {

    @Autowired
    private DeptVaccinesStockMapper deptVaccinesStockMapper;

    @Override
    public List<Long> getVaccinesIdsByDeptId(Long deptId) {
        List<Long> vaccinesIdList = new ArrayList<>();
        List<Integer> vaccinesIds = deptVaccinesStockMapper.selectDeptVaccineIdsByDeptId(deptId);

        //格式转换
        for (Integer vaccinesId : vaccinesIds) {
            long longValue = vaccinesId.longValue();
            vaccinesIdList.add(longValue);
        }

        return vaccinesIdList;
    }

    @Override
    public Integer getAdequateByVid(Long vaccinesId, Long deptId) {

        return  deptVaccinesStockMapper.selectAdequateByVidAndDeptid(vaccinesId,deptId);
    }

    @Override
    public DeptVaccinesStock getDeptVaccinesStockByDeptIdAndVid(Long deptId, Long vaccinesId) {

        return  deptVaccinesStockMapper.selectOneByDeptIdAndVid(deptId,vaccinesId);
    }

    @Override
    public List<DeptVaccinesStock> getListByDeptIdAndVidList(Long deptId, List<Long> vidList) {
        return deptVaccinesStockMapper.selectListByDeptIdAndVidList(deptId,vidList);
    }

    @Override
    public List<VaccinationVo> getListByDeptId(Long deptId) {
        return deptVaccinesStockMapper.selectListByDeptId(deptId);
    }


}
